import request from '@/utils/request'

//使用枚举存储接口地址

enum Api {
  //获取spu列表
  getSpuListApi = '/admin/product',
  // 添加SPU的API
  saveSpuInfoApi = '/admin/product/saveSpuInfo',
  // 更新SPU的API
  updateSpuInfoApi = '/admin/product/updateSpuInfo',
  // 删除SPU的API
  deleteSpuInfoApi = '/admin/product/deleteSpu',

  // 获取所有trademark数据
  getTrademarkApi = '/admin/product/baseTrademark/getTrademarkList',
  // 获取所有的属性数据
  getBaseSaleAttrApi = '/admin/product/baseSaleAttrList',

  //获取图片列表
  getSpuImageListApi = '/admin/product/spuImageList',

  //获取销售属性列表

  getSpuSaleAttrListApi = '/admin/product/spuSaleAttrList'
}

//定义获取spu的Api
export const reqGetSpuListData = (page: number, limit: number, category3Id: number) => {
  //page和Limit是params参数,category3id是query参数
  return request.get<any, any>(Api.getSpuListApi + `/${page}/${limit}?category3Id=${category3Id}`)
}

//定义一个添加spu数据的接口函数
export const reqSaveSpuInfo = (spuInfo: any) => {
  return request.post<any, any>(Api.saveSpuInfoApi, spuInfo)
}

//定义一个更新spu数据的接口函数

export const reqUpdateSpuInfo = (spuInfo: any) => {
  return request.post<any, any>(Api.updateSpuInfoApi, spuInfo)
}

// 定义一个删除spu信息的接口函数

export const reqDeleteSpuInfo = (spuId: any) => {
  return request.delete(Api.deleteSpuInfoApi + `/${spuId}`)
}

// 获取所有的trademark品牌数据

export const reqGetAllTrademarkList = () => {
  return request.get<any, any>(Api.getTrademarkApi)
}

// 3.6 获取所有的销售属性列表数据

export const reqGetBaseSaleAttrList = () => {
  return request.get(Api.getBaseSaleAttrApi)
}

//修改spu根据 id 获取图片列表

export const reqGetSpuImageList = (spuId: number) => {
  return request.get(Api.getSpuImageListApi + `/${spuId}`)
}

// 修改spu根据 id 获取属性列表
export function reqGetSpuSaleAttrList(spuId: number) {
  return request.get<any, any>(Api.getSpuSaleAttrListApi + `/${spuId}`)
}